import request from "../../utils/request.js" // 请求函数

export default {
	state: {
		indexData: {} // 首页数据
	},
	mutations: {
		// 初始化首页数据
		GETINDEXDATA(state, indexData) {
			state.indexData = indexData
		}
	},
	actions: {
		// 获取首页数据
		async getIndexData({
			commit,
			dispatch,
			state
		}) {
			const result = await request("/getIndexData")
			if (result.code === 200) {
				commit("GETINDEXDATA", result.data)
			}
		}
	},
	getters: {
		// 导航菜单信息
		kingKongList(state){
			return state.indexData.kingKongModule ? state.indexData.kingKongModule.kingKongList : []
		},
		// 政策信息
		policyDescList(state){
			return state.indexData.policyDescList || []
		},
		// 分类信息
		categoryModule(state){
			return state.indexData.categoryModule || []
		}
	}
}
